package ru.vsu.cs.kis.elections.socketexchenge;

import java.io.IOException;
import java.util.concurrent.Callable;

import ru.vsu.cs.kis.elections.socketexchenge.commands.Command;

/**
 * 
 * @author Anton
 *
 */
public class AsynTask implements Callable<Command> {

	private Command command = null;

	public AsynTask(Command command) {
		this.command = command;
	}

	@Override
	public Command call() {
		Integer result = -1;
		try {
			result = command.executeOnClient();
			if (result > 0) {
				System.out.println("ClientTask success");
				return command;
			} else {
				System.out.println("ClientTask failed");
			}
		} catch (IOException e) {
			System.err.println("server command failed");
			e.printStackTrace(System.err);
			return null;
		}
		return null;
	}
}
